<template>
  <el-tabs v-model="activeName">
    <el-tab-pane label="课程详情" name="first">
      <el-row>
        <el-button type="primary" style="float:right;margin-right: 30%" @click="submitDetail">完成</el-button>
      </el-row>
      <br />
      <div>
        <el-tag style="float:left; margin-left:20%">课程简介</el-tag>
        <br />
        <br />
        <el-input
          type="textarea"
          :rows="6"
          placeholder="请输入内容"
          v-model="textarea"
          resize="none"
          style="float:left;margin-left:20%; width:800px"
        ></el-input>
      </div>
    </el-tab-pane>

    <el-tab-pane label="目录" name="second" :disabled="true"></el-tab-pane>

    <el-tab-pane label="评价" name="third" :disabled="true"></el-tab-pane>
  </el-tabs>
</template>


<script>
export default {
  name: "CourseDetails",
  data() {
    return {
      textarea: "",
      activeName: "first",
      id: '',
      title: ''
    };
  },
  methods: {
    submitDetail () {
      var msg = new FormData()
      msg.append("title",this.title)
      msg.append("info",this.textarea)
      msg.append("id",this.id)
      this.uploadFileRequest('/api/course/update',msg).then((res)=>{
        this.$message.info(res.data.msg)
        this.$router.push('/detail?id=' + this.id)
      })
    }
  },
  mounted () {
    this.id = this.$route.query.id
    // console.log('---getTeacherDetail---')
    this.getRequest("/api/course/detail?id=" + this.id)
      .then((res) => {
        // console.log('detailData:', res)
        var data = res.data.data
        this.textarea = data.info
        this.title = data.title
      })
      .catch(res => {
        alert("获取数据时发生错误，请刷新重试")
      });
  }
};
</script>

<style scoped>
#content {
  width: 65%;
  height: auto;
  word-wrap: break-word;
  word-break: break-all;
  overflow: hidden;
  font-size: 14px;
  color: #323232;
  font-family: "微软雅黑";
}
#comment {
  width: 65%;
  height: auto;
  word-wrap: break-word;
  word-break: break-all;
  overflow: hidden;
  font-size: 14px;
  color: #303133;
  font-family: "微软雅黑";
}
#userName {
  width: 100%;
  height: auto;
  word-wrap: break-word;
  word-break: break-all;
  overflow: hidden;
  font-size: 14px;
  color: #606266;
  font-family: "微软雅黑";
}
</style>


